home *** CD-ROM | disk | FTP | other *** search
/ A.C.E. 2 / ACE CD 2.iso / FILES / UTILS / AMOSPRO4.DMS / in.adf / Tutorials / Rainbows.AMOS / Rainbows.amosSourceCode
Encoding:
AMOS Source Code  |  1992-09-28  |  7.1 KB  |  270 lines

  1. '*************************** 
  2. '*    AMOS Professional    *             INSTRUCTIONS COVERED
  3. '*                         * 
  4. '*        RAINBOWS         *            Set Rainbow (line  25)     
  5. '*                         *            Rainbow     (line  64)       
  6. '* (c) Europress Software  *            Rain        (line  85)       
  7. '*                         *            Rainbow Del (line 101)   
  8. '*     Ronnie Simpson      * 
  9. '*************************** 
  10. '
  11. '------------------------------------------- 
  12. 'GENERAL 
  13. '------------------------------------------- 
  14. 'Rainbows allow each scan line of the screen to be any one of the 4096 
  15. 'available colours and works equally well in all screen modes including  
  16. '2 colour. 
  17. 'A maximum of 4 rainbows can be defined at any one time. 
  18. 'Do not use rainbows on a colour which is currently being animated with
  19. 'the Flash command.
  20. 'Only a single rainbow can affect a single scan line, if 2 rainbows overlap  
  21. 'then the one with the highest screen position will be given priority and if   
  22. '2 rainbows start at the same position then the one with the lowest  
  23. 'identification number will be viewed. 
  24. '------------------------------------------- 
  25. 'Set Rainbow 
  26. '------------------------------------------- 
  27. 'set a rainbow definition
  28. '
  29. '
  30. '                +---->Rainbow identification number   
  31. '                | +---->Colour index number to be affected  
  32. '                | |  +---->Size of table required   
  33. '                | |  |     +---->Red components 
  34. '                | |  |     |           +----> Blue components 
  35. '                | |  |    /|\         /|\         +---->Green components    
  36. '                | |  |   / | \       / | \       /|\  
  37. '    Set Rainbow 1,0,32,"(1,1,15)","(1,-1,15)","(1,2,15)"
  38. '
  39. 'Identification number - maximum of four rainbows (range 0-3)  
  40. '  Colour index number - only colours 0-15 can be altered by the rainbows
  41. '        Size of table - 1 entry for each colour value on screen (16-65500)
  42. '
  43. 'Colour components  "(1,1,15)" 
  44. '                     | |  | 
  45. '                     | |  +---->Number of times operation is to be repeated 
  46. '                     | +---->Number to be added to each colour change   
  47. '                     +---->Number of scan lines for each colour change    
  48. '------------------------------------------- 
  49. 'EXAMPLE OF SET RAINBOW
  50. '------------------------------------------- 
  51. '                 Set Rainbow 2,4,16,"","(3,-1,15)","" 
  52. '
  53. 'Set rainbow number 2 to affect colour index number 4, the size of table 
  54. 'is 16 to cover the number of different colours. 
  55. 'Ignore the red component and change the green component by subtracting  
  56. '-1 from the step count and affecting 3 scan lines at each step and repeat 
  57. 'this operation 15 times.
  58. 'Ignore the blue components. 
  59. '
  60. 'When the colour component reaches the maximum of 15 (or 0 if step size is 
  61. 'negative) then a new value is calculated by:-   new=old Mod 15                
  62. '
  63. '------------------------------------------- 
  64. 'Rainbow 
  65. '------------------------------------------- 
  66. 'display rainbow on the screen   
  67. '
  68. 'The Set Rainbow instruction only defines the rainbow in order to display
  69. 'it the Rainbow command is used. 
  70. '
  71. '              +---->identification number of the rainbow to be displayed
  72. '              | +---->offset value of the first colour
  73. '              | |  +---->vertical position on screen  
  74. '              | |  |  +---->height in scan lines
  75. '              | |  |  | 
  76. '      Rainbow 1,0,50,200
  77. '
  78. 'Changing the offset value will roll the rainbow colours on screen.  
  79. 'Changing the vertical position will cause the rainbow to scroll up and
  80. 'down the screen.
  81. 'The minimum value for the vertical position is 40 and anything below this 
  82. 'will only be shown from scan line 40.   
  83. '
  84. '------------------------------------------- 
  85. 'Rain
  86. '------------------------------------------- 
  87. 'change colour of 1 scan line
  88. '
  89. 'In order to use this powerful instruction a rainbow with dummy values 
  90. 'must first be set up. 
  91. '                     eg.  Set Rainbow 1,1,255,"","",""    
  92. '                          Rainbow 1,1,40,200  
  93. '
  94. '                +---->rainbow identification number 
  95. '                |  +---->the scan line number to be affected  
  96. '                |  |     +---->the colour value to be assigned  
  97. '                |  |     |
  98. '          Rain (1,100)=2038 
  99. '
  100. '------------------------------------------- 
  101. 'Rainbow Del 
  102. '------------------------------------------- 
  103. 'Delete 1 or all of the rainbows 
  104. '
  105. 'eg          Rainbow Del 3 (delete rainbow number 3) 
  106. '
  107. 'If used without parameters then all rainbows will be deleted. 
  108. '
  109. '------------------------------------------- 
  110. 'WORKING EXAMPLES
  111. '------------------------------------------- 
  112. Dim C$(9)
  113. '
  114. Rem *** Tidy up the screen and print title 
  115. '
  116. Curs Off : Flash Off : Cls 3 : Hide 
  117. Palette $0,$F00,$F0,$F,$F0,$F0F,$FF
  118. Pen 6 : Paper 3 : Double Buffer 
  119. Centre "AMOS Professional RAINBOWS"
  120. Wait 30
  121. Fade 5,,,,0 : Wait 75
  122. '
  123. '
  124. Rem set 3 coloured bars
  125. '
  126. Set Rainbow 0,3,60,"","","(2,1,15)(2,-1,15)"
  127. Set Rainbow 1,3,60,"","(2,1,15)(2,-1,15)",""
  128. Set Rainbow 2,3,60,"(2,1,15)(2,-1,15)","",""
  129. Rainbow 0,0,60,60
  130. Rainbow 1,0,122,60
  131. Rainbow 2,0,184,60
  132. Wait 100
  133. '
  134. '
  135. Rem *** rolling bars 
  136. '
  137. For N=0 To 2
  138. For T=1 To 3
  139. For Y=0 To 59
  140. Rainbow N,Y,,
  141. Wait Vbl 
  142. Next 
  143. Next 
  144. Next 
  145. For T=1 To 3
  146. For Y=59 To 0 Step -1
  147. Rainbow 0,Y,,
  148. Rainbow 1,Y,,
  149. Rainbow 2,Y,,
  150. Wait Vbl 
  151. Next 
  152. Next 
  153. Wait 20
  154. '
  155. '
  156. Rem *** scrolling bars 
  157. '
  158. For Y=60 To 122
  159. Rainbow 0,,Y,
  160. Wait Vbl 
  161. Next 
  162. Wait 20
  163. For Y=122 To 184
  164. Rainbow 1,,Y,
  165. Wait Vbl 
  166. Next 
  167. Wait 20
  168. For Y=184 To 60 Step -1
  169. Rainbow 2,,Y,
  170. Wait Vbl 
  171. Next 
  172. Wait 20
  173. '
  174. '
  175. Rem *** a screen-sized multi-coloured rainbow  
  176. '
  177. Rainbow Del 1
  178. Rainbow Del 2
  179. For H=1 To 200
  180. Set Rainbow 0,3,200,"(1,-1,15)","(2,1,15)","(3,1,15)"
  181. Rainbow 0,0,50,H
  182. Next 
  183. Wait 30
  184. '
  185. '
  186. Rem *** 3 changing /scrolling / multi-coloured bars  
  187. '
  188. C$(1)="(2,1,15)(2,-1,15)"
  189. C$(2)="(1,1,15)(1,-1,15)"
  190. C$(3)="(1,2,15)(1,-2,15)"
  191. C$(4)="(1,3,15)(1,-3,15)"
  192. C$(5)="(5,1,15)(5,-1,15)"
  193. C$(6)="(1,1,6)(1,-1,6)"
  194. C$(7)="(3,3,5)(3,-3,5)"
  195. C$(8)=""
  196. C$(9)=""
  197. Locate 0,22 : Centre "MULTI-COLOURED"
  198. For N=1 To 10
  199. Set Rainbow 0,3,60,C$(Rnd(8)+1),C$(Rnd(8)+1),C$(Rnd(8)+1)
  200. Set Rainbow 1,3,60,C$(Rnd(8)+1),C$(Rnd(8)+1),C$(Rnd(8)+1)
  201. Set Rainbow 2,3,60,C$(Rnd(8)+1),C$(Rnd(8)+1),C$(Rnd(8)+1)
  202. For Y=254 To 50 Step -1
  203. Rainbow 0,3,Y,60
  204. Rainbow 1,3,Y+62,60
  205. Rainbow 2,3,Y+124,60
  206. For DELAY=1 To 80 : Next 
  207. Next 
  208. Wait 20
  209. For Y=50 To 254
  210. Rainbow 0,,Y,
  211. Rainbow 1,3,Y+62,60
  212. Rainbow 2,3,Y+124,60
  213. For DELAY=1 To 20 : Next 
  214. Next 
  215. Wait 20
  216. Next 
  217. Wait 20
  218. '
  219. '
  220. Rem *** show all 4096 colours
  221. '
  222. D=1 : Y=0
  223. Locate 0,22 : Centre "ALL THE COLOURS OF THE RAINBOW"
  224. Rainbow Del 
  225. Wait 50
  226. Set Rainbow 0,3,160,"","",""
  227. For P=0 To 4096
  228. Add Y,D
  229. If Y=1 Then D=1
  230. If Y=159 Then D=-1
  231. Rain(0,Y)=P
  232. Rainbow 0,0,60,160
  233. For DELAY=1 To 4 : Next 
  234. Next 
  235. '
  236. '
  237. Rem *** a neat disappearing trick
  238. '
  239. For Y=1 To 79
  240. Rain(0,Y)=0
  241. Rain(0,160-Y)=0
  242. Rainbow 0,0,60,170
  243. Wait Vbl 
  244. Next 
  245. Wait 50
  246. '
  247. '
  248. Rem *** rainbows with patterns 
  249. '
  250. Cls 0
  251. Set Rainbow 0,3,60,"","","(1,1,15)(1,-1,15)"
  252. Set Rainbow 1,3,60,"","(1,1,15)(1,-1,15)",""
  253. Set Rainbow 2,3,60,"(1,1,15)(1,-1,15)","",""
  254. Rainbow 0,0,60,60
  255. Rainbow 1,0,122,60
  256. Rainbow 2,0,184,60
  257. For N=1 To 15
  258. Ink 3,0
  259. Set Pattern N+4
  260. Bar 0,0 To 319,199
  261. Wait 30
  262. Ink 0,3
  263. Set Pattern N+19
  264. Bar 80,50 To 240,150
  265. Wait 30
  266. Next 
  267. Wait 50
  268. '
  269. '
  270. Edit